package com.glwan.activitytest_2;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.glwan.activitytest_2.bean.Student;
import com.glwan.activitytest_2.bean.Teacher;

import java.util.ArrayList;

public class SecondActivity extends AppCompatActivity {
    private TextView mText;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_second);
        mText = findViewById(R.id.text);
        Intent intent = getIntent();
        String s = intent.getStringExtra("name");
        mText.setText(s);
        Log.e("test123", "============onCreate============");

        Log.e("test123", "====boolean===" + intent.getBooleanExtra("boolean", false));
        Log.e("test123", "====byte===" + intent.getByteExtra("byte", (byte) 0));
        Log.e("test123", "====char===" + intent.getCharExtra("char", '0'));
        Log.e("test123", "====short===" + intent.getShortExtra("short", (short) 0));
        Log.e("test123", "====int===" + intent.getIntExtra("int",  0));
        Log.e("test123", "====long===" + intent.getLongExtra("long",  0L));
        Log.e("test123", "====float===" + intent.getFloatExtra("float",  0.1F));
        Log.e("test123", "====double===" + intent.getDoubleExtra("double",  0.1));

        Bundle bundle = intent.getBundleExtra("bundle");
        Log.e("test123", "====bundle int===" + bundle.getInt("int"));
        Log.e("test123", "====bundle boolean===" + bundle.getBoolean("boolean"));

        int intArray[] = intent.getIntArrayExtra("intArray");
        for (int i : intArray) {
            Log.e("test123", "====int array===" + i);
        }

        ArrayList<String> list = intent.getStringArrayListExtra("list");
        for (String s1 : list) {
            Log.e("test123", "====String array===" + s1);
        }

        Student student = (Student) intent.getSerializableExtra("student");
        Log.e("test123", "====student===" + student.toString());

        Teacher teacher = intent.getParcelableExtra("teacher");
        Log.e("test123", "====teacher===" + teacher.toString());
    }

    @Override
    protected void onStart() {
        super.onStart();
        Log.e("test123", "============onStart============");
    }

    @Override
    protected void onRestart() {
        super.onRestart();
        Log.e("test123", "============onRestart============");
    }

    @Override
    protected void onResume() {
        super.onResume();
        Log.e("test123", "============onResume============");
    }

    @Override
    protected void onPause() {
        super.onPause();
        Log.e("test123", "============onPause============");
    }

    @Override
    protected void onStop() {
        super.onStop();
        Log.e("test123", "============onStop============");
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        Log.e("test123", "============onDestroy============");
    }
}
